package com.shujia.day14;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class Code04FileCopy1 {
    public static void main(String[] args) throws IOException {
        /*
            把当前项目目录下的a.txt内容复制到当前项目目录下的b.txt中
            分析：
                1、先通过字节流的形式将数据读取出来，之后再去将数据写出到文件中
         */

        FileInputStream fileInputStream = new FileInputStream("data/copy/a.txt");
        FileOutputStream fileOutputStream = new FileOutputStream("data/copy/b.txt");

        byte[] bytes = new byte[4];
        int read = 0;

        while ((read = fileInputStream.read(bytes)) != -1) {
            // 之后再去将数据写出到文件中
            fileOutputStream.write(bytes);
        }

        fileInputStream.close();
        fileOutputStream.close();


    }
}
